<?php

namespace App\Models\Car;

use Illuminate\Database\Eloquent\Model;

class Car extends Model
{
    protected $table = 'cars';

    public $dateFormat = 'Y-m-d H:i:s';

    public $statusText = [0=>'审核中',1=>'已审核'];

    public $appends = ['status_text'];

    protected $is_allow_text = [0 => '不允许', 1 => '允许'];

    public function getIsAllowAttribute($key)
    {
        return $this->is_allow_text[$key];
    }

    public function getStatusTextAttribute(){
        if($this['status']) {
            return $this->statusText[$this['status']];
        }else{
            return $this->statusText[0];
        }
    }

    public function carDriver(){
        return $this->hasOne('App\Models\Car\CarDriver','car_id','id');
    }

    public function wayBill(){
        return $this->hasOne('App\Models\Cargo\WayBill','car_card','number');
    }
}
